# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: stef <l0ls0fo2i@ctrlc.hu>
# Contributor: Eivind Uggedal <eu@eju.no>
# Contributor: Nico Schottelius <nico.schottelius@ungleich.ch>
# Maintainer: Justin Berthault <justin.berthault@zaclys.net>
pkgname=mu
pkgver=1.4.12
pkgrel=0
pkgdesc="A collection of utilities for indexing and searching Maildirs"
arch="all !armv7 !x86 !s390x !mips64" # gmime-dev (armv7, x86), limited by emacs (s390x, mips64)
url="http://www.djcbsoftware.nl/code/mu"
license="GPL-3.0"
depends="sqlite"
makedepends="
	autoconf
	automake
	emacs
	gettext-dev
	gmime-dev
	libtool
	texinfo
	sqlite-dev
	xapian-core-dev
	"
subpackages="$pkgname-doc mu4e"
source="$pkgname-$pkgver.tar.gz::https://github.com/djcb/mu/archive/$pkgver.tar.gz"

prepare() {
	default_prepare
	autoreconf --force --install
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-webkit \
		--disable-gtk  \
		--enable-mu4e
	make
}

package() {
	make DESTDIR=$pkgdir install

	if [ -f toys/msg2pdf/msg2pdf ]; then
		install -m755 toys/msg2pdf/msg2pdf $pkgdir/usr/bin/msg2pdf
	fi
	if [ -f toys/mug/mug ]; then
		install -m755 toys/mug/mug $pkgdir/usr/bin/mug
		install -Dm644 toys/mug/mug.svg $pkgdir/usr/share/pixmaps/mug.svg
	fi
}

mu4e() {
	pkgdesc="Emacs-based e-mail client which uses mu as its back-end"
	depends="$pkgname=$pkgver-r$pkgrel cmd:emacs"

	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/share "$subpkgdir"/usr
}

sha512sums="7e376a58fed80ed1110ad342e3578a427779d4fd715990ce5b87d50b6c2488774b47f9b151dca80bb8723eee8db99699f97df975d199dae0d75576f5c2ebc35a  mu-1.4.12.tar.gz"
